package entertainmentguide.entity;

import java.util.StringTokenizer;
/**
 *
 * 
 */
public class Restaurant {
    private int restId;
    private String restaurantName;
    private String address;
    private String phone;
    private String description;
    private String information;
    private String photo;
    private int categoryId;
    private int areaId;
    private int priceRangeId;

    public Restaurant(int restId, String restaurantName, String address,
            String phone, String description, String information,
            String photo, int categoryId, int areaId, int priceRangeId) {
        this.restId = restId;
        this.restaurantName = restaurantName;
        this.address = address;
        this.phone = phone;
        this.description = description;
        this.information = information;
        this.photo=photo;
        this.categoryId = categoryId;
        this.areaId = areaId;
        this.priceRangeId = priceRangeId;
    }

    public Restaurant() {
        this.restId=0; // το ID θα παραχθεί αυτόματα από την database
    }
        
    public void setRestId(int restId) { // ΝΑ ΔΩ ΑΝ ΧΡΕΙΑΖΕΤΑΙ - ΑΦΟΥ ΕΙΝΑΙ ΑΥΤΟΜΑΤΟ
        this.restId = restId;
    }

    public int getRestId() {
        return restId;
    }
    
    public void setRestaurantName(String restaurantName) {
        this.restaurantName = restaurantName;
    }

    public String getRestaurantName() {
        return restaurantName;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getAddress() {
        return address;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getPhone() {
        return phone;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public void setInformation(String information) {
        this.information = information;
    }

    public String getInformation() {
        return information;
    }
    
    public void setPhoto(String photo) {
        this.photo = photo;
    }

    public String getPhoto() {
        return photo;
    }
    
    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }

    public int getCategoryId() {
        return categoryId;
    }
    
    public void setAreaId(int areaId) {
        this.areaId = areaId;
    }

    public int getAreaId() {
        return areaId;
    }

    public void setPriceRangeId(int priceRangeId) {
        this.priceRangeId = priceRangeId;
    }

    public int getPriceRangeId() {
        return priceRangeId;
    }
    
    @Override
    public String toString(){
        return  "\n" + " | " + "ID: " + getRestId() + " | " +
                "Όνομα: " + getRestaurantName() + " | " +
                "Διεύθυνση: " + getAddress() + " | " +
                "Τηλέφωνο: " + getPhone() + " | " +
                "Περιγραφή: " + getDescription() + " | " +
                "Πληροφορίες: " + getInformation() + " | " +
                "Αρχείο Φωτογραφίας: " + getPhoto() + " | " ;
    }

    /**
     * Creates a Restaurant object by parsing line.
     * The line must be in the following format:
     * RESTAURANT: <restId> <restaurantName> <address> <phone> <description> <information>
     *
     * @param line
     * @return
     */
    public static Restaurant parseRestaurant(String line) throws IllegalArgumentException{
        StringTokenizer strTok = new StringTokenizer(line);
        String s1 = strTok.nextToken(); // Restaurant:
        String s2 = strTok.nextToken(); // restId
        String s3 = strTok.nextToken(); // restaurantName
        String s4 = strTok.nextToken(); // address
        String s5 = strTok.nextToken(); // phone
        String s6 = strTok.nextToken(); // description
        String s7 = strTok.nextToken(); // information
        String s8 = strTok.nextToken(); // photo
        String s9 = strTok.nextToken(); // categoryId
        String s10 = strTok.nextToken(); // areaId
        String s11 = strTok.nextToken(); // priceRangeId
        strTok.nextToken("\""); //Skip the first toker with "

        int d2 = Integer.parseInt(s2);
        int d9 = Integer.parseInt(s9);
        int d10 = Integer.parseInt(s10);
        int d11 = Integer.parseInt(s11);

        return new Restaurant(d2,s3,s4,s5,s6,s7,s8,d9,d10,d11);
    }

}
